home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / shells / zsh-3.000 / zsh-3 / home / ftp / pub / local / info / zsh.info-1 (.txt) < prev    next >
GNU Info File  |  1996-07-16  |  48KB  |  1,003 lines

  1. This is Info file zsh.info, produced by Makeinfo-1.63 from the input
  2. file ./zsh.texi.
  3. This is a texinfo version of the man page for the Z Shell, originally by
  4. Paul Falstad.  It was converted from the `zsh.1' file distributed with
  5. zsh v2.5.0 by Jonathan Hardwick, `jch@cs.cmu.edu' and updated/modified
  6. by Clive Messer, `clive@epos.demon.co.uk' to it's present state.
  7. File: zsh.info,  Node: Top,  Next: The Z Shell Guide,  Prev: (dir),  Up: (dir)
  8. The Z Shell Guide
  9. *****************
  10. This Info file documents Zsh, a freely available UNIX command
  11. interpreter (shell), which of the standard shells most closely
  12. resembles the Korn shell (ksh), although it is not completely
  13. compatible.
  14. Document Edition 2.1.2, last updated 8 July 1996, of `The Z Shell
  15. Guide', for zsh, Version 3.0.
  16. * Menu:
  17. * The Z Shell Guide::
  18. * Introduction::
  19. * Invocation::
  20. * Shell Grammar::
  21. * Expansion::
  22. * Redirection::
  23. * Command Execution::
  24. * Functions::
  25. * Jobs & Signals::
  26. * Arithmetic Evaluation::
  27. * Conditional Expressions::
  28. * Zsh Line Editor::
  29. * Parameters::
  30. * Options::
  31. * Shell Builtin Commands::
  32. * Programmable Completion::
  33.  -- Indices --
  34. * Concept Index::
  35. * Variables Index::
  36. * Options Index::
  37. * Functions Index::
  38. * Editor Functions Index::
  39. * Keystroke Index::
  40.  -- The Detailed Node Listing --
  41. Introduction
  42. * Author::
  43. * Availability::
  44. * Undocumented Features::
  45. * Mailing Lists::
  46. * Further Information::
  47. Shell Grammar
  48. * Simple Commands & Pipelines::
  49. * Precommand Modifiers::
  50. * Complex Commands::
  51. * Alternate Forms For Complex Commands::
  52. * Reserved Words::
  53. * Comments::
  54. * Aliasing::
  55. * Quoting::
  56. Expansion
  57. * Filename Expansion::
  58. * Process Substitution::
  59. * Parameter Expansion::
  60. * Command Substitution::
  61. * Arithmetic Expansion::
  62. * Brace Expansion::
  63. * Filename Generation::
  64. * History Expansion::
  65. Zsh Line Editor
  66. * Movement::
  67. * History Control::
  68. * Modifying Text::
  69. * Arguments::
  70. * Completion::
  71. * Miscellaneous::
  72. Parameters
  73. * Array Parameters::
  74. * Positional Parameters::
  75. * Parameters Set By The Shell::
  76. * Parameters Used By The Shell::
  77. Programmable Completion
  78. * Command Flags::
  79. * Options Flags::
  80. * Alternative Completion::
  81. * Extended Completion::
  82. * Example::
  83. File: zsh.info,  Node: The Z Shell Guide,  Next: Introduction,  Prev: Top,  Up: Top
  84. The Z Shell Guide
  85. *****************
  86. This document has been produced from the texinfo file `zsh.texi',
  87. included in the `Doc' sub-directory of the Zsh distribution.
  88. Origins
  89. =======
  90. The texinfo guide was originally put together by Jonathan Hardwick,
  91. `jch@cs.cmu.edu', who converted the `zsh.1' file distributed with zsh
  92. v2.5.0.  After a period of neglect it was updated by Clive Messer,
  93. `clive@epos.demon.co.uk' to reflect the many changes made to both the
  94. shell, the original `zsh.1', (which due to it's size and ever
  95. increasing number of options has since been split into several
  96. man-pages: `zsh.1', `zshall.1', `zshbuiltins.1', `zshcompctl.1',
  97. `zshcompctl.1', `zshexpn.1', `zshmisc.1', `zshoptions.1', `zshparam.1',
  98. `zshzle.1'), and also now includes other useful information from the
  99. `META-FAQ'.
  100. Producing documentation from zsh.texi.
  101. ======================================
  102. Whilst this guide for the most part duplicates the man-pages, (suitably
  103. marked-up into texinfo), and is not intended to replace them, it does
  104. offer several advantages over them, not least that the texinfo source
  105. may be converted into several formats. ie.
  106. The Info guide.
  107.      The Info format allows searching for topics, commands, functions,
  108.      etc.  from the many Indices. The command `makeinfo zsh.texi' is
  109.      used to produce the Info documentation.
  110. The printed guide.
  111.      The command `texi2dvi zsh.texi' will output `zsh.dvi' which can
  112.      then be processed with `dvips' and optionally `gs' (Ghostscript) to
  113.      produce a nicely formatted printed guide.
  114.      (For those without TeX, `zsh.dvi.gz' and `zsh.ps.gz' are available
  115.      for download from FIXME_URL.)
  116. The html guide.
  117.      Mark Borges, `mdb@cdc.noaa.gov', maintains a html version of this
  118.      guide at `http://www.mal.com/zsh/Doc/test/zsh_toc.html'.
  119.      (The html version is produced with `texi2html', which may be
  120.      obtained from `http://wwwcn.cern.ch/dci/texi2html/'. The command
  121.      is, `texi2html -split_chapter -expandinfo zsh.texi')
  122. Future
  123. ======
  124. This guide is actively maintained by Clive Messer,
  125. `clive@epos.demon.co.uk', and Mark Borges, `mdb@cdc.noaa.gov'.
  126. Patches, comments, criticism, and suggestions should be sent to either
  127. of the above or alternatively, the "zsh-workers" mailing list,
  128. `zsh-workers@math.gatech.edu'.
  129. File: zsh.info,  Node: Introduction,  Next: Invocation,  Prev: The Z Shell Guide,  Up: Top
  130. Introduction
  131. ************
  132. Zsh is a UNIX command interpreter (shell) usable as an interactive login
  133. shell and as a shell script command processor.  Of the standard shells,
  134. zsh most closely resembles ksh but includes many enhancements.  Zsh has
  135. command line editing, builtin spelling correction, programmable command
  136. completion, shell functions (with autoloading), a history mechanism,
  137. and a host of other features.
  138. * Menu:
  139. * Author::
  140. * Availability::
  141. * Undocumented Features::
  142. * Mailing Lists::
  143. * Further Information::
  144. File: zsh.info,  Node: Author,  Next: Availability,  Up: Introduction
  145. Author
  146. ======
  147. Zsh was originally written by Paul Falstad, `pf@software.com'.
  148. Programmable completion was implemented by Sven Wischnowsky,
  149. `oberon@cs.tu-berlin.de' and Peter Stephenson,
  150. `P.Stephenson@swansea.ac.uk'.  Richard Coleman,
  151. `coleman@math.gatech.edu' did some major cleanups in the code and made
  152. zsh very portable using GNU autoconf.  Zsh is currently maintained by
  153. the members of the zsh workers mailing list,
  154. `zsh-workers@math.gatech.edu' and coordinated by Zoltan Hidvegi,
  155. `hzoli@cs.elte.hu'.
  156. File: zsh.info,  Node: Availability,  Next: Undocumented Features,  Prev: Author,  Up: Introduction
  157. Availability
  158. ============
  159. Zsh is available from the following anonymous ftp sites.  The first is
  160. the official archive site.  The rest are mirror sites which are kept
  161. frequently up to date.  The sites marked with `(G)' may mirror
  162. `ftp.math.gatech.edu' instead of the primary site.
  163. Hungary
  164.      `ftp://ftp.cs.elte.hu/pub/zsh/'
  165. Australia
  166.      `ftp://ftp.ips.oz.au/pub/packages/zsh/'  `(G)'
  167. France
  168.      `ftp://ftp.cenatls.cena.dgac.fr/pub/shells/zsh/'
  169. Germany
  170.      `ftp://ftp.uni-trier.de/pub/unix/shell/zsh/'
  171.      `ftp://ftp.prz.tu-berlin.de/pub/unix/shells/zsh/'
  172.      `ftp://ftp.fu-berlin.de/pub/unix/shells/zsh/'  `(G)'
  173. Japan
  174.      `ftp://ftp.tohoku.ac.jp/mirror/zsh/'
  175.      `ftp://ftp.iij.ad.jp/pub/misc/zsh/'  `(G)'
  176. Norway
  177.      `ftp://ftp.uit.no/pub/unix/shells/zsh/'  `(G)'
  178. Sweden
  179.      `ftp://ftp.lysator.liu.se/pub/unix/zsh/'
  180.      `ftp://ftp.net.lut.ac.uk/zsh/'
  181.      `ftp://ftp.math.gatech.edu/pub/zsh/'
  182.      `ftp://uiarchive.cso.uiuc.edu/pub/packages/shells/zsh/'
  183.      `ftp://ftp.sterling.com/zsh/'  `(G)'
  184.      `ftp://ftp.rge.com/pub/shells/zsh/'  `(G)'
  185. File: zsh.info,  Node: Undocumented Features,  Next: Mailing Lists,  Prev: Availability,  Up: Introduction
  186. Undocumented Features
  187. =====================
  188. Known only to the recipients of the `zsh-workers' mailing list.
  189. To join the mailing lists, see *Note Mailing Lists::.
  190. File: zsh.info,  Node: Mailing Lists,  Next: Further Information,  Prev: Undocumented Features,  Up: Introduction
  191. Mailing Lists
  192. =============
  193. Zsh has 3 mailing lists:
  194. `zsh-announce@math.gatech.edu'
  195.      Announcements about releases, major changes in the shell and the
  196.      monthly posting of the Zsh FAQ. (moderated)
  197. `zsh-users@math.gatech.edu'
  198.      User discussions.
  199. `zsh-workers@math.gatech.edu'
  200.      Hacking, development, bug reports and patches.
  201. To subscribe, send mail with the SUBJECT `subscribe <e-mail-address>'
  202. to the associated administrative address for the mailing list.
  203. `zsh-announce-request@math.gatech.edu'
  204. `zsh-users-request@math.gatech.edu'
  205. `zsh-workers-request@math.gatech.edu'
  206. YOU ONLY NEED TO JOIN ONE OF THE MAILING LISTS AS THEY ARE NESTED.
  207. All submissions to `zsh-announce' are automatically forwarded to
  208. `zsh-users'.
  209. All submissions to `zsh-users' are automatically forwarded to
  210. `zsh-workers'.
  211. Un-subscribing is done similarly.
  212. If you have problems subscribing/unsubscribing to any of the mailing
  213. lists, send mail to Richard Coleman, `coleman@math.gatech.edu'.
  214. File: zsh.info,  Node: Further Information,  Prev: Mailing Lists,  Up: Introduction
  215. Further Information
  216. ===================
  217. * Menu:
  218. * The Zsh FAQ::
  219. * The Zsh Web Page::
  220. * See Also::
  221. File: zsh.info,  Node: The Zsh FAQ,  Next: The Zsh Web Page,  Up: Further Information
  222. The Zsh FAQ
  223. -----------
  224. Zsh has a list of Frequently Asked Questions (FAQ) maintained by Peter
  225. Stephenson, `P.Stephenson@swansea.ac.uk'.  It is regularly posted to
  226. the newsgroup `comp.unix.shell' and the `zsh-announce' mailing list.
  227. The latest version can be found at any of the Zsh ftp sites, or at:
  228. `http://www.mal.com/zsh/FAQ/'
  229. File: zsh.info,  Node: The Zsh Web Page,  Next: See Also,  Prev: The Zsh FAQ,  Up: Further Information
  230. The Zsh Web Page
  231. ----------------
  232. Zsh has a web page maintained by Mark Borges, `mdb@cdc.noaa.gov' which
  233. is located at: `http://www.mal.com/zsh/'.
  234. File: zsh.info,  Node: See Also,  Prev: The Zsh Web Page,  Up: Further Information
  235. See Also
  236. --------
  237. sh(1), csh(1), tcsh(1), rc(1), bash(1), ksh(1), zshbuiltins(1),
  238. zshcompctl(1), zshexpn(1), zshparam(1), zshzle(1), zshoptions(1),
  239. zshmisc(1)
  240. File: zsh.info,  Node: Invocation,  Next: Shell Grammar,  Prev: Introduction,  Up: Top
  241. Invocation
  242. **********
  243. If the `-s' flag is not present and an argument is given, the first
  244. argument is taken to be the pathname of a script to execute.  The
  245. remaining arguments are assigned to the positional parameters.  The
  246. following flags are interpreted by the shell when invoked:
  247. `-c STRING'
  248.      Read commands from STRING.
  249.      Force shell to be interactive.
  250.      Read command from the standard input.
  251. Startup/Shutdown Files
  252. ======================
  253. Commands are first read from `/etc/zshenv'.  If the `-f' flag is given
  254. or if the `NO_RCS' option is set within `/etc/zshenv', all other
  255. initialization files are skipped.  Otherwise, commands are read from
  256. `$ZDOTDIR/.zshenv' (if `ZDOTDIR' is unset, `HOME' is used instead).  If
  257. the first character of argument zero passed to the shell is `-', or if
  258. the `-l' flag is present, then the shell is assumed to be a login
  259. shell, and commands are read from `/etc/zprofile' and then
  260. `$ZDOTDIR/.zprofile'.  Then, if the shell is interactive and the
  261. `NO_RCS' option is unset, commands are read from `/etc/zshrc' and then
  262. `$ZDOTDIR/.zshrc'.  Finally, if the shell is a login shell,
  263. `/etc/zlogin' and `$ZDOTDIR/.zlogin' are read.
  264. Files
  265. =====
  266. $ZDOTDIR/.zshenv
  267. $ZDOTDIR/.zprofile
  268. $ZDOTDIR/.zshrc
  269. $ZDOTDIR/.zlogin
  270. $ZDOTDIR/.zlogout
  271. ${TMPPREFIX}*  (default is /tmp/zsh*)
  272. /etc/zshenv
  273. /etc/zprofile
  274. /etc/zshrc
  275. /etc/zlogin
  276. /etc/zlogout
  277. File: zsh.info,  Node: Shell Grammar,  Next: Expansion,  Prev: Invocation,  Up: Top
  278. Shell Grammar
  279. *************
  280. * Menu:
  281. * Simple Commands & Pipelines::
  282. * Precommand Modifiers::
  283. * Complex Commands::
  284. * Alternate Forms For Complex Commands::
  285. * Reserved Words::
  286. * Comments::
  287. * Aliasing::
  288. * Quoting::
  289. File: zsh.info,  Node: Simple Commands & Pipelines,  Next: Precommand Modifiers,  Up: Shell Grammar
  290. Simple Commands
  291. ===============
  292. A "simple command" is a sequence of optional parameter assignments
  293. followed by blank-separated words, with optional redirections
  294. interspersed.  The first word is the command to be executed, and the
  295. remaining words, if any, are arguments to the command.  If a command
  296. name is given, the parameter assignments modify the environment of the
  297. command when it is executed.  The value of a simple command is its exit
  298. status, or 128 plus the signal number if terminated by a signal.
  299. A "pipeline" is a sequence of one or more commands separated by `|' or
  300. `|&'.  `|&' is shorthand for `2>&1 |'.  The standard output of each
  301. command is connected to the standard input of the next command in the
  302. pipeline.  If a pipeline is preceded by `coproc', it is executed as a
  303. coprocess; a two-way pipe is established between it and the parent
  304. shell.  The shell can read from or write to the coprocess by means of
  305. the `>&p' and `<&p' redirection operators.  The value of a pipeline is
  306. the value of the last command.  If a pipeline is not preceded by `!',
  307. the value of that pipeline is the logical `NOT' of the value of the
  308. last command.
  309. A "sublist" is a sequence of one or more pipelines separated by `&&' or
  310. `||'.  If two pipelines are separated by `&&', the second pipeline is
  311. executed only if the first is successful (returns a zero value).  If
  312. two pipelines are separated by `||', the second is executed only if the
  313. first is unsuccessful (returns a nonzero value).  Both operators have
  314. equal precedence and are left associative.
  315. A "list" is a sequence of one or more sublists separated by, and
  316. optionally terminated by, `;', `&', `&|', `&!', or a newline.  Normally
  317. the shell waits for each list to finish before executing the next one.
  318. If a list is terminated by a `&', `&|', or `&!', the shell executes it
  319. in the background, and does not wait for it to finish.
  320. File: zsh.info,  Node: Precommand Modifiers,  Next: Complex Commands,  Prev: Simple Commands & Pipelines,  Up: Shell Grammar
  321. Precommand Modifiers
  322. ====================
  323. A simple command may be preceded by a "precommand" modifier which will
  324. alter how the command is interpreted.  These modifiers are shell builtin
  325. commands with the exception of `nocorrect' which is a reserved word.
  326.      The command is executed with a `-' prepended to its `argv[0]'
  327.      string.
  328. `noglob'
  329.      Filename generation (globbing) is not performed on any of the
  330.      words.
  331. `nocorrect'
  332.      Spelling correction is not done on any of the words.
  333. `exec'
  334.      The command is executed in the parent shell without forking.
  335. `command'
  336.      The command word is taken to be the name of an external command,
  337.      rather than a shell function or builtin.
  338. File: zsh.info,  Node: Complex Commands,  Next: Alternate Forms For Complex Commands,  Prev: Precommand Modifiers,  Up: Shell Grammar
  339. Complex Commands
  340. ================
  341. A "complex command" in zsh is one of the following:
  342. `if LIST'
  343. `then LIST'
  344. `[ elif LIST ; then LIST ] ...'
  345. `[ else LIST ]'
  346.      The `if LIST' is executed, and, if it returns a zero exit status,
  347.      the `then LIST' is executed.  Otherwise, the `elif LIST' is
  348.      executed and, if its value is zero, the `then LIST' is executed.
  349.      If each `elif LIST' returns nonzero, the `else LIST' is executed.
  350. `for NAME [ in WORD ... ]'
  351. `do LIST'
  352. `done'
  353.      Expand the list of WORDs, and set the parameter NAME to each of
  354.      them in turn, executing LIST each time.  If the `in WORD' is
  355.      omitted, use the positional parameters instead of the WORDs.
  356. `for NAME [ in WORD ... ] ; SUBLIST'
  357.      This is a shorthand for the previous form.  It is included for
  358.      convenience, but its use in scripts is discouraged, unless SUBLIST
  359.      is a command of the form { LIST }.
  360. `for NAME in WORD ...'
  361. `LIST'
  362.      Another form of `for'.
  363. `foreach NAME ( WORD ... )'
  364. `LIST'
  365. `end'
  366.      Another form of `for'.
  367. `while LIST'
  368. `do LIST'
  369. `done'
  370.      Execute the `do LIST' as long as the `while LIST' returns a zero
  371.      exit status.
  372. `until LIST'
  373. `do LIST'
  374. `done'
  375.      Execute the `do LIST' as long as the `until LIST' returns a
  376.      nonzero exit status.
  377. `repeat WORD'
  378. `do LIST'
  379. `done'
  380.      WORD is expanded and treated as an arithmetic expression, which
  381.      must evaluate to a number N.  LIST is then executed N times.
  382. `repeat WORD SUBLIST'
  383.      This is a short form of `repeat'.
  384. `case WORD in [ [(] PATTERN [ | PATTERN ] ... ) LIST ;; ] ... esac'
  385.      Execute the LIST associated with the first PATTERN that matches
  386.      WORD, if any.  The form of the patterns is the same as that used
  387.      for filename generation.  *Note Filename Generation::.
  388. `case WORD { [ [(] PATTERN [ | PATTERN ] ... ) LIST ;; ] ... }'
  389.      Another form of `case'.
  390. `select NAME [ in WORD ... ]'
  391. `do LIST'
  392. `done'
  393.      Print the set of WORDs, each preceded by a number.  If the `in
  394.      WORD' is omitted, use the positional parameters.  The `PROMPT3'
  395.      prompt is printed and a line is read from standard input.  If this
  396.      line consists of the number of one of the listed WORDs, then the
  397.      parameter NAME is set to the WORD corresponding to this number.
  398.      If this line is empty, the selection list is printed again.
  399.      Otherwise, the value of the parameter NAME is set to null.  The
  400.      contents of the line read from standard input is saved in the
  401.      parameter `REPLY'.  LIST is executed for each selection until a
  402.      break or end-of-file is encountered.
  403. `select NAME [ in WORD ] ; SUBLIST'
  404.      A short form of `select'.
  405. `( LIST )'
  406.      Execute LIST in a subshell.
  407. `{ LIST }'
  408.      Execute LIST.
  409. `function WORD [ () ] ... { LIST }'
  410. `WORD ... () { LIST }'
  411. `WORD ... () SUBLIST'
  412.      Define a function which is referenced by any one of WORD.
  413.      Normally, only one WORD is provided; multiple WORDs are usually
  414.      only useful for setting traps.  The body of the function is the
  415.      LIST between the `{' and `}'.  *Note Functions::.
  416. `time [ PIPELINE ]'
  417.      The PIPELINE is executed, and timing statistics are reported on
  418.      the standard error in the form specified by the `TIMEFMT'
  419.      parameter.  If PIPELINE is omitted, print statistics about the
  420.      shell process and its children.
  421. `[[ EXP ]]'
  422.      Evaluates the conditional expression EXP and return a zero exit
  423.      status if it is true.  *Note Conditional Expressions::, for a
  424.      description of EXP.
  425. File: zsh.info,  Node: Alternate Forms For Complex Commands,  Next: Reserved Words,  Prev: Complex Commands,  Up: Shell Grammar
  426. Alternate Forms For Complex Commands
  427. ====================================
  428. Many of zsh's complex commands have alternate forms.  These particular
  429. versions of complex commands should be considered deprecated and may be
  430. removed in the future.  The versions in the previous section should be
  431. preferred instead.
  432. `if LIST {'
  433. `LIST'
  434. `} elif LIST {'
  435. `LIST'
  436. `} ... else {'
  437. `LIST'
  438.      An alternate form of `if'.
  439. `if LIST'
  440. `SUBLIST'
  441.      A shorter form of previous one which only works if `NO_SHORT_LOOPS'
  442.      is not set.
  443. `for NAME ( WORD ... ) {'
  444. `LIST'
  445.      An alternate form of `for'.
  446. `for NAME ( WORD ... ) SUBLIST'
  447.      A shorter form of the previous one which only works if
  448.      `NO_SHORT_LOOPS' is not set.
  449. `while LIST {'
  450. `LIST'
  451.      An alternate form of `while'.
  452. File: zsh.info,  Node: Reserved Words,  Next: Comments,  Prev: Alternate Forms For Complex Commands,  Up: Shell Grammar
  453. Reserved Words
  454. ==============
  455. The following words are recognized as "reserved words" when used as the
  456. first word of a command unless quoted or removed using `disable -r':
  457. `do' `done' `esac' `then' `elif' `else' `fi' `for' `case' `if' `while'
  458. `function' `repeat' `time' `until' `select' `coproc' `nocorrect'
  459. `foreach' `end'
  460. File: zsh.info,  Node: Comments,  Next: Aliasing,  Prev: Reserved Words,  Up: Shell Grammar
  461. Comments
  462. ========
  463. In non-interactive shells, or in interactive shells with the
  464. `INTERACTIVE_COMMENTS' option set, a word beginning with the third
  465. character of the `histchars' parameter (`#' by default) causes that
  466. word and all the following characters up to a newline to be ignored.
  467. File: zsh.info,  Node: Aliasing,  Next: Quoting,  Prev: Comments,  Up: Shell Grammar
  468. Aliasing
  469. ========
  470. Every token in the shell input is checked to see if there is an alias
  471. defined for it.  If so, it is replaced by the text of the alias if it is
  472. in command position (if it could be the first word of a simple command),
  473. or if the alias is global.  If the text ends with a space, the next word
  474. in the shell input is treated as though it were in command position for
  475. purposes of alias expansion.  An alias is defined using the `alias'
  476. builtin; global aliases may be defined using the `-g' option to that
  477. builtin.
  478. Alias substitution is done on the shell input before any other
  479. substitution except history substitution.  Therefore, if an alias is
  480. defined for the word `foo', alias substitution may be avoided by
  481. quoting part of the word, e.g. `\foo'.  But there is nothing to prevent
  482. an alias being defined for `\foo' as well.
  483. File: zsh.info,  Node: Quoting,  Prev: Aliasing,  Up: Shell Grammar
  484. Quoting
  485. =======
  486. A character may be "quoted" (that is, made to stand for itself) by
  487. preceding it with a `\'.  `\' followed by a newline is ignored.  All
  488. characters enclosed between a pair of single quotes (`''') are quoted,
  489. except the first character of `histchars' (`!' by default).  A single
  490. quote cannot appear within single quotes.  Inside double quotes (`""'),
  491. parameter and command substitution occurs, and `\' quotes the
  492. characters `\', ``', `"', and `$'.
  493. File: zsh.info,  Node: Expansion,  Next: Redirection,  Prev: Shell Grammar,  Up: Top
  494. Expansion
  495. *********
  496. The types of expansions performed are "history expansion", "alias
  497. expansion", "process substitution", "parameter expansion", "command
  498. substitution", "arithmetic expansion", "brace expansion", "filename
  499. expansion", and "filename generation".
  500. Expansion is done in the above specified order in five steps.  The
  501. first is "history expansion" which is only performed in interactive
  502. shells.  The next step is "alias expansion" which is done right before
  503. the command line is parsed.  They are followed by "process
  504. substitution", "parameter expansion", "command substitution",
  505. "arithmetic expansion", and "brace expansion" which are performed in
  506. one step in left-to-right fashion.  After these expansions, all
  507. unquoted occurrences of the characters `\', `'', and `"' are removed
  508. and the result is subjected to "filename expansion" followed by
  509. "filename generation".
  510. * Menu:
  511. * Filename Expansion::
  512. * Process Substitution::
  513. * Parameter Expansion::
  514. * Command Substitution::
  515. * Arithmetic Expansion::
  516. * Brace Expansion::
  517. * Filename Generation::
  518. * History Expansion::
  519. File: zsh.info,  Node: Filename Expansion,  Next: Process Substitution,  Up: Expansion
  520. Filename Expansion
  521. ==================
  522. Each word is checked to see if it begins with an unquoted `~'.  If it
  523. does, then the word up to a `/', or the end of the word if there is no
  524. `/', is checked to see if it can be substituted in one of the ways
  525. described here.  If so, then the `~' and the checked portion are
  526. replaced with the appropriate substitute value.
  527. A `~' by itself is replaced by the value of the `HOME' parameter.  A
  528. `~' followed by a `+' or a `-' is replaced by the value of `PWD' or
  529. `OLDPWD', respectively.
  530. A `~' followed by a number is replaced by the directory at that
  531. position in the directory stack.  `~0' is equivalent to `~+', and `~1'
  532. is the top of the stack.  `~+' followed by a number is replaced by the
  533. directory at that position in the directory stack.  `~+0' is equivalent
  534. to `~+', and `~+1' is the top of the stack.  `~-' followed by a number
  535. is replaced by the directory that many positions from the bottom of the
  536. stack.  `~-0' is the bottom of the stack.  The `PUSHD_MINUS' option
  537. exchanges the effects of `~+' and `~-' where they are followed by a
  538. number.
  539. A `~' followed by anything not already covered is looked up as a named
  540. directory, and replaced by the value of that named directory if found.
  541. Named directories are typically home directories for users on the
  542. system.  They may also be defined if the text after the `~' is the name
  543. of a string shell parameter whose value begins with a `/'.  It is also
  544. possible to define directory names using the `-d' option to the `hash'
  545. builtin.
  546. In  certain circumstances (in prompts, for instance), when the shell
  547. prints a path, the path is checked to see if it has a named directory
  548. as its prefix.  If so, then the prefix portion is replaced with a `~'
  549. followed by the name of the directory.  The shortest way of referring
  550. to the directory is used, with ties broken in favour of using a named
  551. directory, except when the directory is `/'.
  552. If a word begins with an unquoted `=' and the `NO_EQUALS' option is not
  553. set, the remainder of the word is taken as the name of a command or
  554. alias.  If a command exists by that name, the word is replaced by the
  555. full pathname of the command.  If an alias exists by that name, the
  556. word is replaced with the text of the alias.
  557. Filename expansion is performed on the right hand side of a parameter
  558. assignment, including those appearing after commands of the `typeset'
  559. family.  In this case, the right hand side will be treated as a
  560. colon-separated list in the manner of `PATH' so that a `~' or an `='
  561. following a `:' is eligible  for expansion.  All such behavior can be
  562. disabled by quoting the `~', the `=', or the whole expression (but not
  563. simply the colon); the `NO_EQUALS' option is also respected.
  564. If the option `MAGIC_EQUAL_SUBST' is set, any unquoted shell argument in
  565. the form `IDENTIFIER=EXPRESSION' becomes eligible for file expansion as
  566. described in the previous  paragraph.  Quoting the first `=' also
  567. inhibits this.
  568. File: zsh.info,  Node: Process Substitution,  Next: Parameter Expansion,  Prev: Filename Expansion,  Up: Expansion
  569. Process Substitution
  570. ====================
  571. Each command argument of the form `<(LIST)', `>(LIST)' or `=(LIST)' is
  572. subject to process substitution.  In the case of the `<' and `>' forms,
  573. the shell will run process LIST asynchronously, connected to a named
  574. pipe (FIFO).  The name of this pipe will become the argument to the
  575. command.  If the form with `>' is selected then writing to this file
  576. will provide input for LIST.  If `<' is used, then the file passed as
  577. an argument will be a named pipe connected to the output of the LIST
  578. process.  For example,
  579.    `paste <(cut -f1 FILE1) <(cut -f3 FILE2) | tee >(PROCESS1)
  580. >(PROCESS2) >/dev/null'
  581. `cut's fields 1 and 3 from the files FILE1 and FILE2 respectively,
  582. `paste's the results together, and sends it to the processes PROCESS1
  583. and PROCESS2.  Note that the file, which is passed as an argument to
  584. the command, is a system pipe so programs that expect to `lseek(2)' on
  585. the file will not work.  Also note that the previous example can be
  586. more compactly and efficiently written as:
  587.    `paste <(cut -f1 FILE1) <(cut -f3 FILE2) >>(PROCESS1) >>(PROCESS2)'
  588. The shell uses pipes instead of FIFOs to implement the latter two
  589. process substitutions in the above example.
  590. If `=' is used, then the file passed as an argument will be the name of
  591. a temporary file containing the output of the LIST process.  This may
  592. be used instead of the `<' form for a program that expects to
  593. `lseek(2)' on the input file.
  594. File: zsh.info,  Node: Parameter Expansion,  Next: Command Substitution,  Prev: Process Substitution,  Up: Expansion
  595. Parameter Expansion
  596. ===================
  597. The character `$' is used to introduce parameter expansions.  *Note
  598. Parameters::, for a description of parameters.  In the expansions
  599. discussed below that require a pattern, the form of the pattern is the
  600. same as that used for filename generation; *Note Filename Generation::.
  601. `${NAME}'
  602.      The value, if any, of the parameter NAME is substituted.  The
  603.      braces are required if NAME is followed by a letter, digit, or
  604.      underscore that is not to be interpreted as part of its name.  If
  605.      NAME is an array parameter, then the values of each element of
  606.      NAME is substituted, one element per word.  Otherwise, the
  607.      expansion results in one word only; no word splitting is done on
  608.      the result.
  609. `${+NAME}'
  610.      If NAME is the name of a set parameter, `1' is substituted,
  611.      otherwise `0' is substituted.
  612. `${NAME:-WORD}'
  613.      If NAME is set and is non-null then substitute its value;
  614.      otherwise substitute WORD; the value of the parameter is then
  615.      substituted.
  616. `${NAME:=WORD}'
  617.      If NAME is unset or is null then set it to WORD; the value of the
  618.      parameter is then substituted.
  619. `${NAME::=WORD}'
  620.      Set NAME to WORD; the value of the parameter is then substituted.
  621. `${NAME:?WORD}'
  622.      If NAME is set and is non-null, then substitute its value;
  623.      otherwise, print WORD and exit from the shell.  If WORD is
  624.      omitted, then a standard message is printed.
  625. `${NAME:+WORD}'
  626.      If NAME is set and is non-null then substitute WORD; otherwise
  627.      substitute nothing.
  628. `${NAME#PATTERN}'
  629. `${NAME##PATTERN}'
  630.      If the PATTERN matches the beginning of the value of NAME, then
  631.      substitute the value of NAME with the matched portion deleted;
  632.      otherwise, just substitute the value of NAME.  In the first form,
  633.      the smallest matching pattern is preferred; in the second form,
  634.      the largest matching pattern is preferred.  If name is an array and
  635.      the substitution is not quoted or the `@' flag or the `NAME[@]'
  636.      syntax is used, matching is performed on each array elements
  637.      separately.
  638. `${NAME%PATTERN}'
  639. `${NAME%%PATTERN}'
  640.      If the PATTERN matches the end of the value of NAME, then
  641.      substitute the value of NAME with the matched portion deleted;
  642.      otherwise, just substitute the value of NAME.  In the first form,
  643.      the smallest matching pattern is preferred; in the second form, the
  644.      largest matching pattern is preferred.  If name is an array and
  645.      the substitution is not quoted or the `@' flag or the `NAME[@]'
  646.      syntax is used, matching is performed on each array elements
  647.      separately.
  648. `${NAME:#PATTERN}'
  649.      If the pattern matches the value of NAME, then substitute the empty
  650.      string; otherwise, just substitute the value of NAME.  If NAME is
  651.      an array and the substitution is not quoted or the `@' flag or the
  652.      `NAME[@]' syntax is used, matching is performed on each array
  653.      elements separately, and the matched array elements are removed
  654.      (use the `M' flag to remove the non-matched elements).
  655. `${#SPEC}'
  656.      If SPEC is one of the above substitutions, substitute the length
  657.      in characters of the result instead of the result itself.  If SPEC
  658.      is an array expression, substitute the number of elements of the
  659.      result.
  660. `${^SPEC}'
  661.      Toggle the value of the `RC_EXPAND_PARAM' option for the evaluation
  662.      of SPEC; if the `^' is doubled, turn it off.  When this option is
  663.      set, array expansions of the form `foo${xx}bar', where the
  664.      parameter `xx' is set to `(a b c)', are substituted with `fooabar
  665.      foobbar foocbar' instead of the default `fooa b cbar'.
  666. `${=SPEC}'
  667.      Toggle the value of the `SH_WORD_SPLIT' option for the evaluation
  668.      of SPEC; if the `=' is doubled, turn it off.  When this option is
  669.      set, parameter values are split into separate words using `IFS' as
  670.      a delimiter before substitution.  This is done by default in most
  671.      other shells.
  672. `${~SPEC}'
  673.      Toggle the value of the `GLOB_SUBST' option for the evaluation of
  674.      SPEC; if the `~' is doubled, turn it off.  When this option is set,
  675.      any pattern characters resulting from the substitution become
  676.      eligible for file expansion and filename generation.
  677. If the colon is omitted from one of the above expressions containing a
  678. colon, then the shell only checks whether NAME is set or not, not
  679. whether it is null.
  680. If a `${...}' type parameter expression or a `$(...)' type command
  681. substitution is used in place of NAME above, it is substituted first
  682. and the result is used as it were the value of NAME.
  683. If the opening brace is directly followed by an opening parenthesis the
  684. string up to the matching closing parenthesis will be taken as a list
  685. of flags.  Where arguments are valid, any character, or the matching
  686. pairs `(...)', `{...}', `[...]', or `<...>', may be used in place of
  687. the colon as delimiters.  The following flags are supported:
  688.      Create an array parameter with `${...:=...}' or `${...::=...}'.
  689.      Assignment is made before sorting or padding.
  690.      In double quotes, array elements are put into separate words. Eg.
  691.      `${(@)FOO}' is equivalent to `${FOO[@]}' and `${(@)FOO[1,2]}' is
  692.      the same as `$FOO[1]' `$FOO[2]'.
  693.      Perform "parameter expansion", "command substitution" and
  694.      "arithmetic expansion" on the result.  Such expansions can be
  695.      nested but too deep recursion may have unpredictable effects.
  696.      Sort the resulting words in ascending order.
  697.      Sort the resulting words in descending order.
  698.      With `o' or `O', makes the sort case-insensitive.
  699.      Converts all letters in the result to lowercase.
  700.      Converts all letters in the result to uppercase.
  701.      Capitalizes the resulting words
  702.      With `${#NAME}', count the total number of characters in an array,
  703.      as if the elements were concatenated with spaces between them.
  704.      With `${#NAME}', count words in arrays or strings; the `s' flag
  705.      may be used to set a word delimiter.
  706.      Similar to `w' with the difference that empty words between
  707.      repeated delimiters are also counted.
  708.      Recognize the same escape sequences as the `print' builtin in
  709.      string arguments to subsequent flags.
  710. `l:EXPR::STRING1::STRING2:'
  711.      Pad the resulting words on the left.  Each word will be truncated
  712.      if required and placed in a field EXPR characters wide.  The space
  713.      to the left will be filled with STRING1 (concatenated as often as
  714.      needed), or spaces if STRING1 is not given.  If both STRING1 and
  715.      STRING2 are given, this string will be placed exactly once
  716.      directly to the left of the resulting word.
  717. `r:EXPR::STRING1::STRING2:'
  718.      As `l', but pad the words on the right.
  719. `j:STRING:'
  720.      Join the words or arrays together using STRING as a separator.
  721.      Note that this occurs before word splitting by the `SH_WORD_SPLIT'
  722.      option.
  723.      Join the words of arrays together using newline as a separator.
  724.      This is a shorthand for `pj:\n:'.
  725. `s:STRING:'
  726.      Force word splitting (see the option `SH_WORD_SPLIT') at the
  727.      separator STRING.  Splitting only occurs in places where an array
  728.      value is valid.
  729.      Split the result of the expansion to lines.  This is a shorthand
  730.      for `ps:\n:'.
  731.      (This and all remaining flags are used with the `${...#...}' and
  732.      `${...%...}' forms).  Search substrings as well as beginnings or
  733.      ends.
  734. `I:EXPR:'
  735.      Search the EXPR'th match (where EXPR evaluates to a number).
  736.      Include the matched portion in the result.
  737.      Include the unmatched portion in the result (the Rest).
  738.      Include the index of the beginning of the match in the result.
  739.      Include the index of the end of the match in the result.
  740.      Include the length of the match in the result.
  741. File: zsh.info,  Node: Command Substitution,  Next: Arithmetic Expansion,  Prev: Parameter Expansion,  Up: Expansion
  742. Command Substitution
  743. ====================
  744. A command enclosed in parentheses preceded by a dollar sign, like so:
  745. `$(...)' or quoted with grave accents: ``...`' is replaced with its
  746. standard output, with any trailing newlines deleted.  If the
  747. substitution is not enclosed in double quotes, the output is broken into
  748. words using the `IFS' parameter.  The substitution `$(CAT FOO)' may be
  749. replaced by the equivalent but faster `$(<FOO)'.  In either case, if the
  750. option `GLOB_SUBST' is set the output is eligible for filename
  751. generation.
  752. File: zsh.info,  Node: Arithmetic Expansion,  Next: Brace Expansion,  Prev: Command Substitution,  Up: Expansion
  753. Arithmetic Expansion
  754. ====================
  755. A string of the form `$[EXP]' is substituted with the value of the
  756. arithmetic expression EXP.  EXP is subjected to "parameter expansion",
  757. "command substitution" and "arithmetic expansion" before it is
  758. evaluated.  *Note Arithmetic Evaluation::.
  759. File: zsh.info,  Node: Brace Expansion,  Next: Filename Generation,  Prev: Arithmetic Expansion,  Up: Expansion
  760. Brace Expansion
  761. ===============
  762. A string of the form `foo{xx,yy,zz}bar' is expanded to the individual
  763. words `fooxxbar', `fooyybar', and `foozzbar'.  Left-to-right order is
  764. preserved.  This construct may be nested.  Commas may be quoted in
  765. order to include them literally in a word.
  766. An expression of the form `{X-Y}', where X and Y are single characters,
  767. is expanded to every character between X and Y, inclusive.
  768. An expression of the form `{N1..N2}', where N1 and N2 are integers, is
  769. expanded to every number between N1 and N2, inclusive.  If either
  770. number begins with a zero, all the resulting numbers will be padded
  771. with leading zeroes to that minimum width.  If the numbers are in
  772. decreasing order the resulting sequence will also be in decreasing
  773. order.
  774. If a brace expression matches none of the above forms, it is left
  775. unchanged, unless the `BRACE_CCL' option is set.  In that case, it is
  776. expanded to a sorted list of the individual characters between the
  777. braces, in the manner of a search set.  `-' is treated specially as in
  778. a search set, but `^' or `!' as the first character is treated normally.
  779. File: zsh.info,  Node: Filename Generation,  Next: History Expansion,  Prev: Brace Expansion,  Up: Expansion
  780. Filename Generation
  781. ===================
  782. If a word contains an unquoted instance of one of the characters `*',
  783. `|', `<', `[', or `?', it is regarded as a pattern for filename
  784. generation, unless the `NO_GLOB' option is set.  If the `EXTENDED_GLOB'
  785. option is set, the `^', `~', and `#' characters also denote a pattern;
  786. otherwise (except for an initial `~', *Note Filename Expansion::) they
  787. are not treated specially by the shell.  The word is replaced with a
  788. list of sorted filenames that match the pattern.  If no matching
  789. pattern is found, the shell gives an error message, unless the
  790. `NULL_GLOB' option is set, in which case the word is deleted; or unless
  791. the `NO_NOMATCH' option is set, in which case the word is left
  792. unchanged.  In filename generation, the character `/' must be matched
  793. explicitly; also, a `.' must be matched explicitly at the beginning of
  794. a pattern or after a `/', unless the `GLOB_DOTS' option is set.  No
  795. filename generation pattern matches the files `.' or `..'.  In other
  796. instances of pattern matching, the `/' and `.' are not treated
  797. specially.
  798.      Matches any string, including the null string.
  799.      Matches any character.
  800. `[...]'
  801.      Matches any of the enclosed characters. Ranges of characters can
  802.      be specified by separating two characters by a `-'.  A `-' or `]'
  803.      may be matched by including it as the first character in the list.
  804. `[^...]'
  805. `[!...]'
  806.      Like `[...]', except that it matches any character which is not in
  807.      the given set.
  808. `<x-y>'
  809.      Matches any number in the range `x' to `y', inclusive.  If `x' is
  810.      omitted, the number must be less than or equal to `y'.  If `y' is
  811.      omitted, the number must be greater than or equal to `x'.  A
  812.      pattern of the form `<>' matches any number.
  813.      Matches anything except the pattern `x'.
  814. `x|y'
  815.      Matches either `x' or `y'.
  816.      Matches zero or more occurrences of the pattern `x'.
  817. `x##'
  818.      Matches one or more occurrences of the pattern `x'.
  819. Parentheses may be used for grouping.  Note that the `|' character must
  820. be within parentheses, so that the lexical analyzer does not think it
  821. is a pipe character.  Also note that `/' has a higher precedence than
  822. `^'; that is:
  823.    `ls ^foo/bar'
  824. will search directories in `.' except `./foo' for a file named `bar'.
  825. A pathname component of the form `(FOO/)#' matches a path consisting of
  826. zero or more directories matching the pattern FOO.  As a shorthand,
  827. `**/' is equivalent to `(*/)#'.  Thus:
  828.    `ls (*/)#BAR'
  829.    `ls **/BAR'
  830. does a recursive directory search for files named BAR, not following
  831. symbolic links.  For this you can use the form `***/'.
  832. If used for filename generation, a pattern may contain an exclusion
  833. specifier.  Such patterns are of the form `PAT1~PAT2'.  This pattern
  834. will generate all files matching PAT1, but which do not match PAT2.
  835. For example, `*.c~lex.c' will match all files ending in `.c', except
  836. the file `lex.c'.  This may appear inside parentheses.  Note that `~'
  837. has higher precedence than `|', so that `pat1|pat2~pat3' matches any
  838. time that PAT1 matches, or if PAT2 matches while PAT3 does not.  Note
  839. also that any `/' characters are not treated specially in the exclusion
  840. specifier, so that a `*' will match multiple path segments if they
  841. appear in the pattern to the left of the `~'.
  842. Patterns used for filename generation may also end in a list of
  843. qualifiers enclosed in parentheses.  The qualifiers specify which
  844. filenames that otherwise match the given pattern will be inserted in the
  845. argument list.  A qualifier may be any one of the following:
  846.      Directories
  847.      Plain files
  848.      Symbolic links
  849.      Sockets
  850.      Named pipes (FIFOs)
  851.      Executable plain files (0100)
  852.      Device files (character or block special)
  853.      Block special files
  854.      Character special files
  855.      owner-readable files (0400)
  856.      owner-writable files (0200)
  857.      owner-executable files (0100)
  858.      group-readable files (0040)
  859.      group-writable files (0020)
  860.      group-executable files (0010)
  861.      world-readable files (0004)
  862.      world-writable files (0002)
  863.      world-executable files (0001)
  864.      Setuid files (04000)
  865.      Setgid files (02000)
  866.      files with the sticky bit (01000)
  867. `dDEV'
  868.      Files on the device DEV
  869. `l[+|-]CT'
  870.      Files having a link count less than `CT (-)', greater than `CT
  871.      (+)', or is equal to `CT'.
  872.      Files owned by the effective user id.
  873.      Files owned by the effective group id.
  874. `uID'
  875.      Files owned by user ID if ID is a number.  If not, the character
  876.      after the `u' will be used as a separator and the string between
  877.      it and the next matching separator (`(', `[', `{', and `<' match
  878.      `)', `]', `}', and `>' respectively; any other character matches
  879.      itself) will be taken as a user name and translated into the
  880.      corresponding user id (e.g.  `u:foo:' or `u[foo]' for user `foo').
  881. `gID'
  882.      Like `uID' but with group ids or names.
  883. `a[Mwhm][-|+]N'
  884.      Files accessed exactly N days ago.  Files accessed within the last
  885.      N days are selected using a negative value for N (`-n').  Files
  886.      accessed more than N days ago are selected by a positive N value
  887.      (`+n').  Optional unit specifiers `M', `w', `h', or `m' (e.g.
  888.      `ah5') cause the check to be performed with months (of 30 days),
  889.      weeks, hours, or minutes instead of days, respectively.  For
  890.      instance, `echo *(ah-5)' would echo files accessed within the last
  891.      five hours.
  892. `m[Mwhm][-|+]N'
  893.      Like the file access qualifier, except that it uses the file
  894.      modification time.
  895. `c[Mwhm][-|+]N'
  896.      Like the file access qualifier, except that it uses the file inode
  897.      change time.
  898. `L[+-]N'
  899.      Files less than N bytes (`-'), more than N bytes (`+'), or exactly
  900.      N bytes in length.  If this flag is directly followed by a `k'
  901.      (`K'), `m' (`M'), or `p' (`P') (e.g. `Lk+50') the check is
  902.      performed with kilobytes, megabytes, or blocks (of 512 bytes)
  903.      instead.
  904.      Negates all qualifiers following it.
  905.      Toggles between making the qualifiers work on symbolic links (the
  906.      default), and the files they point to.
  907.      Sets the `MARK_DIRS' option for the current pattern.
  908.      Appends a trailing qualifier mark to the file names, analogous to
  909.      the `LIST_TYPES', for the current pattern (overrides `M').
  910.      Sets the `NULL_GLOB' option for the current pattern.
  911.      Sets the `GLOB_DOTS' option for the current pattern.
  912. More than one of these lists can be combined, separated by commas; the
  913. whole list matches if at least one of the sublists matches (they are
  914. `or''ed, the qualifiers in the sublists are `and''ed).
  915. If a `:' appears in a qualifier list, the remainder of the expression
  916. in parentheses is interpreted as a modifier (*Note Modifiers::).  Note
  917. that each modifier must be introduced by a separate `:'.  Note also
  918. that the result after modification does not have to be an existing
  919. file.  The name of any existing file can be followed by a modifier of
  920. the form `(:...)' even if no filename generation is performed.
  921. Thus:
  922.    `ls *(-/)'
  923. lists all directories and symbolic links that point to directories, and
  924.    `ls *(%W)'
  925. lists all world-writable device files in the current directory, and
  926.    `ls *(W,X)'
  927. lists all files in the current directory that are world-writable or
  928. world-executable, and
  929.    `echo /tmp/foo*(u0^@:t)'
  930. outputs the basename of all root-owned files beginning with the string
  931. `foo' in `/tmp', ignoring symlinks, and
  932.    `ls *.*~(lex|parse).[ch](^D^l1)'
  933. lists all files having a link count of one whose names contain a dot
  934. (but not those starting with a dot, since `GLOB_DOTS' is explicitly
  935. switched off) except for `lex.c', `lex.h', `parse.c', and `parse.h'. A
  936. `/' at the end of a pattern is equivalent to `(/)'.
  937. File: zsh.info,  Node: History Expansion,  Prev: Filename Generation,  Up: Expansion
  938. History Expansion
  939. =================
  940. History substitution allows you to use words from previous command lines
  941. in the command line you are typing.  This simplifies spelling
  942. corrections and the repetition of complicated commands or arguments.
  943. Command lines are saved in the history list, the size of which is
  944. controlled by the `HISTSIZE' variable.  The most recent command is
  945. retained in any case.  A history substitution begins with the first
  946. character of the `histchars' parameter which is `!' by default and may
  947. occur anywhere on the command line; history substitutions do not nest.
  948. The `!' can be escaped with `\' or can be enclosed between a pair of
  949. single quotes (`''') to suppress its special meaning. Double quotes
  950. will not work for this.
  951. Input lines containing history substitutions are echoed on the terminal
  952. after being expanded, but before any other substitutions take place or
  953. the command gets executed.
  954. * Menu:
  955. * Event Designators::
  956. * Word Designators::
  957. * Modifiers::
  958. File: zsh.info,  Node: Event Designators,  Next: Word Designators,  Up: History Expansion
  959. Event Designators
  960. -----------------
  961. An event designator is a reference to a command-line entry in the
  962. history list.
  963.      Start a history substitution, except when followed by a blank,
  964.      newline, `=', or `('.
  965.      Refer to the previous command.  By itself, this substitution
  966.      repeats the previous command.
  967.      Refer to command-line N.
  968. `!-N'
  969.      Refer to the current command-line minus N.
  970. `!STR'
  971.      Refer to the most recent command starting with STR.
  972. `!?STR[?]'
  973.      Refer to the most recent command containing STR.
  974.      Refer to the current command line typed in so far.  The line is
  975.      treated as if it were complete up to and including the word before
  976.      the one with the `!#' reference.
  977. `!{...}'
  978.      Insulate a history reference from adjacent characters (if
  979.      necessary).
  980. File: zsh.info,  Node: Word Designators,  Next: Modifiers,  Prev: Event Designators,  Up: History Expansion
  981. Word Designators
  982. ----------------
  983. A word designator indicates which word or words of a given command line
  984. will be included in a history reference.  A `:' separates the event
  985. specification from the word designator.  It can be omitted if the word
  986. designator begins with a `^', `$', `*', `-' or `%'.  Word designators
  987. include:
  988.      The first input word (command).
  989.      The N'th argument.
  990.      The first argument, that is, `1'.
  991.      The last argument.
  992.      The word matched by (the most recent) `?STR' search.
  993. `x-y'
  994.      A range of words; `-y' abbreviates `0-y'.
  995.      All the arguments, or a null value if there is just one word in
  996.      the event.
  997.      Abbreviates `x-$'.
  998.      Like `x*' but omitting word `$'.
  999. Note that a `%' word designator will only work when used as `!%',
  1000. `!:%', `!?str?:%' and only when used after a `!?' substitution.
  1001. Anything else will result in an error, although the error may not be
  1002. the most obvious one.
  1003.